package net.yambal.mobile.adv
{
	import flash.utils.Dictionary;
	
	import net.yambal.mobile.adv.manager.ADV_ResouceMng;

	public class ADV_Chapter
	{
		public var id:String;
		public var label:String;
		private var _seen_img_class:Class;
		private var _frame_img_class:Class;
		public var known:Boolean = false;
		public var text_rag:Number = 1;
		
		public var start_paragraph_id:String;
		
		private var _paragraphs:Dictionary;
		
		public function ADV_Chapter(
				_id:String
				, _label:String
				, _start_paragraph_id:String
				, _seen_img:String
				, _frame_img:String
				, paragraphs:Dictionary
				, _known:Boolean
				, _text_rag:Number = 1
				)
		{
			var resouceMng:ADV_ResouceMng = ADV_ResouceMng.getInstance(); 
			
			id = _id;
			label = _label;
			start_paragraph_id = _start_paragraph_id;
			
			_seen_img_class = resouceMng.getImageResouceCls(_seen_img);
			_frame_img_class = resouceMng.getImageResouceCls(_frame_img);
			
			known = _known;
			text_rag = _text_rag;
			
			_paragraphs = paragraphs;
			
			if(start_paragraph_id == null || start_paragraph_id.length == 0){
				trace("Error:no start_paragraph_id" +
					"\n\tchapter " + id + ":" + label);
			}
		}
		
		public function getParagraph(id:String):ADV_Paragraph{
			return _paragraphs[id];
		}
		
		public function get seen_img_obj():Object{
			trace(this + ":seen_img_obj");
			if(this._seen_img_class != null){
				return new _seen_img_class();
			}
			return null;
		}
		
		public function get frame_img_obj():Object{
			trace(this + ":frame_img_obj");
			if(this._frame_img_class != null){
				return new _frame_img_class();
			}
			return null;
		}
		
		public function toString():String{
			return id + ":" + label + "(" + known + ")"
				+ "\n\tstart_paragraph_id:" + start_paragraph_id
				+ "\n\tparagraphs:" + _paragraphs;
		}
	}
}